<!DOCTYPE html>
<html lang="en">
<head>
    <title>签约个人信息</title>
    <meta name="viewport" content="width=device-width,user-scalable=no, initial-scale=1">
    <titleType style="display: none">familyAdd</titleType>
    <%- include('../../_global/baseLibs') %>
    <script src="/static/lib/util.js"></script>
</head>
<script type="text/javascript">
    $(function () {
        var userInfo = JSON.parse(localStorage.getItem('jkcsUserInfo'))
        document.getElementById("name").value = userInfo.xm
        document.getElementById("patientCardId").value = userInfo.sfzh
        document.getElementById("phoneNum").value = userInfo.sj
        $.QuickRemote.AjaxJson({
            funcName: "/api/gzd/yygh/getJzrInfo"
            ,callback: function(result) {
                if(result){
                    var lx = "",lxNum = '';
                    lx = (result.mrjzk.jzklx == 0 && "社保卡") || (result.mrjzk.jzklx == 1 && "医保卡") || (result.mrjzk.jzklx == 2 && "自费卡") || (result.mrjzk.jzklx == 9 && "其他卡")
                    if(result.mrjzk.jzklx === '0') {
                        lxNum = 1
                    }else if(result.mrjzk.jzklx === '1'){
                        lxNum = 2
                    }else if(result.mrjzk.jzklx === '2'){
                        lxNum = 3
                    }
                    $("#relationship").val(lx);
                    $("#relationship").attr('data-type',lxNum);
                    document.getElementById("cardNum").value = result.mrjzk.jzkh;
                }
            }
        });
        $("#jzk").on("click",function () {
            location = "/html/gzd/familyList/familyList.html"
        })
        $("#titleBtn").on("click", function () {
            var obj = (localStorage.getItem("qysq"))?JSON.parse(localStorage.getItem("qysq")):{};
            if(localStorage.getItem('docId')){
                obj.famId = localStorage.getItem('docId')
            }
            obj.name = document.getElementById("name").value;
            var idCard = document.getElementById("patientCardId").value;
            var phone = document.getElementById("phoneNum").value;
            obj.personcard =(idcardCheck.test(idCard))?idCard : $.QuickAlert.alertFail({content: "身份证格式不对"});
            obj.mobilePhone =(phoneCheck.test(phone))?phone : $.QuickAlert.alertFail({content: "手机号格式不对"});
            obj.cardId = document.getElementById("cardNum").value;
            obj.cardKind = $("#relationship").attr("data-type");
            console.log(obj)
            if(document.getElementById("patientCardId").value !== "" && document.getElementById("phoneNum").value !== "" && document.getElementById("cardNum").value !== "" && $("#relationship").attr("data-type") !== ""  && document.getElementById("name").value !== ""){
                if(obj.cardKind == 3 || obj.cardKind == 9){
                    $.QuickAlert.alertFail({content: "只支持社保卡和医保卡"});
                    return;
                }
                localStorage.setItem("qysq", JSON.stringify(obj));
                location = "jzdxx.html";
            }else {
                $.QuickAlert.alertFail({content: "还有信息未填写完整"});
            }
        });
    });
</script>
<body>
<section class="page-wrap page-family">
    <!-- header start -->
    <header id="header" class="header-box grey fixed"  >
        <div class="header-content">
            <div class="left-tool">
                <a class="back" href="javascript:void(0)"><i class="iconfont icon-back"></i></a>
            </div>
            <div class="title">签约个人信息</div>
        </div>
    </header>
    <!-- header end -->
    <!--content start-->
    <section class="content">
        <form id="grxxForm">
        <aside class="plane-box first family-plane">
            <ul class="default-list form-list">
                <li>
                    <div class="item-inner">
                        <div class="item-title">
                            姓名
                        </div>
                        <div class="item-center">
                            <input class="input-text form-control" id="name" name="xm" type="text" placeholder="输入姓名" value=""
                                   quick-config="label:'姓名', validateProxy:'notNull length', length: '16'">
                        </div>
                    </div>
                </li>
                <li>
                    <div class="item-inner">
                        <div class="item-title">
                            身份证
                        </div>
                        <div class="item-center">
                            <input class="input-text form-control" id="patientCardId" name="sfzh" type="text" maxlength="18" placeholder="输入身份证" value=""
                                   quick-config="label:'身份证号', validateProxy:'notNull validPatientCardId'">
                        </div>
                    </div>
                </li>
                <li>
                    <div class="item-inner">
                        <div class="item-title">
                            手机号码
                        </div>
                        <div class="item-center">
                            <input class="input-text form-control" id="phoneNum" name="sj" type="text" maxlength="11" placeholder="输入手机号码" value=""
                                   quick-config="label:'手机', validateProxy:'notNull validPhoneNum'">
                        </div>
                    </div>
                </li>
                <li>
                    <div class="item-inner" id="jzk">
                        <div class="item-title">
                            就诊卡
                        </div>
                        <div class="item-center">
                            <input id="relationship" data-type="0" class="input-text form-control" type="text"  placeholder="选择有效证件" value="" readonly
                                   quick-config="label:'关系', validateProxy:'notNull'">
                            <i class="iconfont icon-more"></i>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="item-inner">
                        <div class="item-title">
                            就诊卡号
                        </div>
                        <div class="item-center">
                            <input class="input-text form-control" id="cardNum" name="sj" type="text" placeholder="输入相应卡号" value=""
                                   quick-config="label:'手机', validateProxy:'notNull validPhoneNum'">
                        </div>
                    </div>
                </li>
            </ul>
        </aside>

        <aside  class="plane-box">
            <ul class="default-list form-list">
                <li>
                    <div class="item-inner">
                        <div class="item-title">
                            居住地址
                        </div>
                    </div>
                </li>
                <li>
                    <div class="item-inner">
                        <div class="item-center">
                            <input class="input-text form-control" id="weight" type="text" name="tz" placeholder="输入居住详细地址" value="" style="text-align: left;padding-left: 0;">
                        </div>
                    </div>
                </li>
            </ul>
        </aside>
        </form>
     <button id="titleBtn" style="width: 100%;height:40px;color: #ffffff;border-radius: 5px;background-color: #AAB5F2;border: none;">下一步</button>
    </section>
    <!--content end-->
</section>
</body>
</html>